package com.starblink.store.memanage.adapter

import android.content.Context
import android.util.AttributeSet
import androidx.constraintlayout.widget.ConstraintLayout
import com.starblink.android.basic.ext.inflater
import com.starblink.basic.util.CommUtils
import com.starblink.rocketreserver.fragment.MerchantWebVOF
import com.starblink.store.databinding.ItemMemanageStoreBinding

class ItemStoreMeManageView @JvmOverloads constructor(
    context: Context,
    attrs: AttributeSet? = null,
    defStyleRes: Int = 0
) : ConstraintLayout(context, attrs, defStyleRes) {
    lateinit var merchat: MerchantWebVOF

    val binding: ItemMemanageStoreBinding = ItemMemanageStoreBinding.inflate(inflater, this, true)

    companion object {
    }


    fun bindPost(
        merchat: MerchantWebVOF,
    ) {
        this.merchat = merchat
//        if (merchat.merchantWebUrl?.isNotEmpty() == true) {
//                binding.tvWeb.text = Uri.parse(merchat.merchantWebUrl).host
//        }
        binding.manage.title.text = merchat.merchantName
        binding.manage.ivStore.load(merchat.logo ?: "", merchat.merchantName)
        if (merchat.subDate != null) {
            var subDate: String = merchat.subDate as String
            subDate = if (subDate.length > 10) subDate.substring(0, 10) else ""
        }
        binding.manage.tags.tvFollowers.text =
            "${merchat.subNum} ${CommUtils.getString(com.starblink.basic.style.R.string.following_2)}"
//        merchat.cornerLabels?.let {
//            binding.manage.tags.ivSale.visibleOrGone(it.isNotEmpty() && it.first().type == 1) {}
//            binding.manage.tags.div.visibleOrGone(it.isNotEmpty() && it.first().type == 1) {}
//        }
    }
}